feat(gateway): add optional openapi-to-mcp sidecar#279
feat(gateway): add optional openapi-to-mcp sidecar#279jarvis9443 wants to merge 4 commits intomainfrom
Conversation
The OpenAPI-to-MCP service has been moved out of the gateway image into a standalone image (api7/openapi-to-mcp). This chart now optionally deploys it as a sidecar in the gateway pod when the openapi-to-mcp / mcp-tools-acl plugins are in use. - Disabled by default; enable via openapiToMcp.enabled=true. - Shares the pod network namespace with the gateway so the plugin can continue to reach it on 127.0.0.1:<port>. - Uses exec-based probes because the upstream server binds to 127.0.0.1 inside the container. - Existing users of the openapi-to-mcp / mcp-tools-acl plugins must set openapiToMcp.enabled=true after upgrading.
📝 WalkthroughWalkthroughAdds Helm values and README documentation for an optional OpenAPI-to-MCP sidecar and updates the gateway pod template to conditionally inject that sidecar (image, port, env, probes, resources) with template-time validation that the sidecar port matches gateway plugin attributes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@charts/gateway/templates/_pod.tpl`:
- Around line 231-273: The template currently wires the sidecar to
.Values.openapiToMcp.port but doesn't validate equality with
pluginAttrs["openapi-to-mcp"].port, allowing silent runtime breakage; add a Helm
template guard at the top of the openapi-to-mcp block that compares
.Values.openapiToMcp.port with index .Values.pluginAttrs "openapi-to-mcp" .port
and calls fail(...) if they differ so the chart rendering fails fast; locate the
openapiToMcp block in _pod.tpl and add the eq check using Helm's eq/if or ne and
fail to produce a clear error message referencing both .Values.openapiToMcp.port
and pluginAttrs["openapi-to-mcp"].port.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aef03d22-ecda-46e0-b474-8f58bef58637
📒 Files selected for processing (3)
charts/gateway/README.mdcharts/gateway/templates/_pod.tplcharts/gateway/values.yaml
OpenAPI2MCP image now binds to 0.0.0.0 by default (via SSE_HOST) in api7/OpenAPI2MCP#40, so we can drop the awkward exec+node probe.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@charts/gateway/templates/_pod.tpl`:
- Around line 232-235: The template currently skips validation when
pluginAttrs.openapi-to-mcp.port is missing; change the logic in the block using
$mcpAttr and the hasKey check so you always validate port alignment: retrieve
pluginPort from (index $mcpAttr "port") using a default/sentinel and then
compare int(pluginPort) to int(.Values.openapiToMcp.port), and if pluginPort is
absent fail when .Values.openapiToMcp.port does not equal the plugin’s expected
default port; update the fail message in the same block to reference
.Values.openapiToMcp.port and the plugin port value so a mismatch is caught even
when pluginAttrs omits the port.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cbd830d4-0bfc-4a74-ba64-9769da0a5de8
📒 Files selected for processing (1)
charts/gateway/templates/_pod.tpl
There was a problem hiding this comment.
🧹 Nitpick comments (1)
charts/gateway/templates/_pod.tpl (1)
232-235: Prefer merged plugin attrs over raw.Values.pluginAttrsto avoid default drift.This works, but using the merged helper output as the source of truth will reduce maintenance risk if base plugin defaults change later.
♻️ Proposed refactor
- {{- $mcpAttr := (index .Values.pluginAttrs "openapi-to-mcp" | default dict) -}} + {{- $pluginAttrs := (include "apisix.pluginAttrs" . | fromYaml) -}} + {{- $mcpAttr := (index $pluginAttrs "openapi-to-mcp" | default dict) -}} {{- $pluginMcpPort := (index $mcpAttr "port" | default 3000 | int) -}}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@charts/gateway/templates/_pod.tpl` around lines 232 - 235, The comparison is reading raw .Values.pluginAttrs via $mcpAttr but should use the chart's merged plugin-attrs helper output to avoid default-drift; replace the lookup currently using (index .Values.pluginAttrs "openapi-to-mcp") with the merged-plugin-attrs variable or helper used elsewhere (e.g., the template variable that holds merged plugin attrs, such as $mergedPluginAttrs or the include/tuple helper that returns merged attrs), then use (index $mergedPluginAttrs "openapi-to-mcp" | default dict) to compute $mcpAttr and keep the rest of the check against .Values.openapiToMcp.port unchanged so plugin defaults remain authoritative.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@charts/gateway/templates/_pod.tpl`:
- Around line 232-235: The comparison is reading raw .Values.pluginAttrs via
$mcpAttr but should use the chart's merged plugin-attrs helper output to avoid
default-drift; replace the lookup currently using (index .Values.pluginAttrs
"openapi-to-mcp") with the merged-plugin-attrs variable or helper used elsewhere
(e.g., the template variable that holds merged plugin attrs, such as
$mergedPluginAttrs or the include/tuple helper that returns merged attrs), then
use (index $mergedPluginAttrs "openapi-to-mcp" | default dict) to compute
$mcpAttr and keep the rest of the check against .Values.openapiToMcp.port
unchanged so plugin defaults remain authoritative.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 061002d3-fc4e-4416-843f-959c88e3bca3
📒 Files selected for processing (1)
charts/gateway/templates/_pod.tpl
Summary
The OpenAPI-to-MCP server has been extracted from the gateway image into a standalone image (
api7/openapi-to-mcp). This PR adds an optional sidecar deployment for it underopenapiToMcpin the gateway chart.Changes
charts/gateway/values.yaml: newopenapiToMcpblock (enabled: false, imageapi7/openapi-to-mcp:0.0.1-beta, port 3000, emptyresources).charts/gateway/templates/_pod.tpl: render the sidecar container whenopenapiToMcp.enabledis true. Shares the pod network namespace so the gateway plugin reaches it on127.0.0.1:<port>.charts/gateway/README.md: regenerated viamake helm-docs.Notes
127.0.0.1inside the container, sohttpGet/tcpSocketprobes from kubelet would fail. The template uses anexecprobe that runs a smallnode -escript against127.0.0.1:$SSE_PORT/health.enabled: false. Users running theopenapi-to-mcpormcp-tools-aclplugins must flip this totrueafter upgrading to a gateway image that no longer bundles the server.Related
Verification
Summary by CodeRabbit
New Features
Documentation